import { Indicator } from 'mint-ui';
import axios from 'axios'
import store from '@/store'
import router from '@/router'
const service = axios.create({
    timeout: 5000
})
service.interceptors.request.use(config => {
    // Indicator.open('加载中...');
    if (store.state.user.token) {
        config.headers.token = store.state.user.token;
    }
    return config
})
service.interceptors.response.use(v => {
    let data = v.data.data;
    if (data.code == 1000) {
        Indicator.close();
        router.push('/login');
        return Promise.reject(new Error('token过期,重新登录'))
    }
    Indicator.close();
    return data
})
export default {
    $axios: service
}